From: Jonas Dreßler Date: Mon, 17 Feb 2020 15:56:10 +0000 (+0100) Subject: appDisplay: Implement an addApp() method for FolderViews X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~751^2^2~162 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=69f6c43b6077bd46c2b3297555922a3a287d5e93;p=gnome-shell.git appDisplay: Implement an addApp() method for FolderViews Similar to removeApp(), implement addApp() in FolderView to make adding folders to views a bit more obvious. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1011 --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 97bf72d6a..042598ddc 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1429,6 +1429,22 @@ class FolderView extends BaseAppView { return apps; } + addApp(app) { + let folderApps = this._folder.get_strv('apps'); + folderApps.push(app.id); + + this._folder.set_strv('apps', folderApps); + + // Also remove from 'excluded-apps' if the app id is listed + // there. This is only possible on categories-based folders. + let excludedApps = this._folder.get_strv('excluded-apps'); + let index = excludedApps.indexOf(app.id); + if (index >= 0) { + excludedApps.splice(index, 1); + this._folder.set_strv('excluded-apps', excludedApps); + } + } + removeApp(app) { let folderApps = this._folder.get_strv('apps'); let index = folderApps.indexOf(app.id); @@ -1459,8 +1475,6 @@ class FolderView extends BaseAppView { } else { this._folder.set_strv('apps', folderApps); } - - return true; } }); @@ -1589,20 +1603,7 @@ var FolderIcon = GObject.registerClass({ if (!this._canAccept(source)) return false; - let app = source.app; - let folderApps = this._folder.get_strv('apps'); - folderApps.push(app.id); - - this._folder.set_strv('apps', folderApps); - - // Also remove from 'excluded-apps' if the app id is listed - // there. This is only possible on categories-based folders. - let excludedApps = this._folder.get_strv('excluded-apps'); - let index = excludedApps.indexOf(app.id); - if (index >= 0) { - excludedApps.splice(index, 1); - this._folder.set_strv('excluded-apps', excludedApps); - } + this.view.addApp(source.app); return true; }